package com.zeny.online.controller;


import com.zeny.online.common.ResponseResult;
import com.zeny.online.entity.ChatMsg;
import com.zeny.online.service.ChatMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/online/chat-msg")
@Api(tags = "消息模块")
public class ChatMsgController {

    @Autowired
    private ChatMsgService chatMsgService;

    @ApiOperation(value = "获取未签收的消息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "acceptUserId", value = "用户ID", required = true)
    })
    @PostMapping("/getUnReadMsgList")
    public ResponseResult getUnReadMsgList(String acceptUserId) {
        if (StringUtils.isBlank(acceptUserId)) {
            return ResponseResult.fail();
        }
        List<ChatMsg> myUnsignChatMsg = chatMsgService.getMyUnsignChatMsg(acceptUserId);
        return ResponseResult.ok().data(myUnsignChatMsg);
    }

}

